var emid ;
var pwd;
var s;
window.onload=function () {
    getUser();
}
function getUser() {
    axios.get("/user/getLoginUser").then(resp=>{
        var info = resp.data;
        emid = info.id;
        pwd=info.password;
    });
}

function check() {
    var usedPwd = $n("userName1").value;
    var newPwd = $n("password").value;
    var newPwds = $n("passwords").value;
    if (usedPwd==pwd){
        if (newPwd!=newPwds ){
            $n("loginDiv").innerHTML="新旧密码不一致";
            s = 0;
        }else {
            $n("loginDiv").innerHTML="";
            s = 1;
        }
    }
    else {
        $n("loginDiv").innerHTML="旧密码不正确";
    }

}

function update() {
    if (s==1){
        axios.get("/user/updatePassword",{
            params:{
                id:emid,
                password:$n("password").value
            }
        }).then(resp=>{
            var info = resp.data;
            if (info=="ok"){
                location.href = "/land/land.html";
            }
        })
    }else {
        $n("loginDiv").innerHTML="请填写完成";
    }
}

function cancel() {
    location.href = "/menu/menu.html";
}
